/*
 * Created by SharpDevelop.
 * User: Michael
 * Date: 13/09/2007
 * Time: 10:10 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Collections.Generic;

namespace SudokuSolver
{
	/// <summary>
	/// Description of Group.
	/// </summary>
	public class Group
	{
		private List<Cell> _Cells;
		
		public List<Cell> Cells {
			get { return _Cells; }
		}
		
		public void AddCell(Cell theCell)
		{
			_Cells.Add(theCell);
		}
		
		public Cell GetCell(int index)
		{
			//returns a cell from 1 to 9
			return _Cells[index - 1];
		}
		
		public bool Solved
		{
			get{
				bool temp = true;
				
				foreach(Cell thisCell in _Cells)
				{
					if(!(thisCell.Found))
						temp = false;
				}
				return temp;
			}
		}
		
		public override string ToString()
		{
			string returnString = "";
			for(int i = 1; i <= 3; i++)
			{
				returnString += GetCell(i).ValueToString;
			}
			returnString += "|";
			for(int i = 4; i <= 6; i++)
			{
				returnString += GetCell(i).ValueToString;
			}
			returnString += "|";
			for(int i = 7; i <= 9; i++)
			{
				returnString += GetCell(i).ValueToString;
			}
			return returnString;
		}
		
		public bool MissingNumber(int number)
		{
			bool returnValue = true;
			foreach(Cell cell in Cells)
			{
				if(cell.Value == number)
					returnValue = false;
			}
			return returnValue;
		}
		
		public Group()
		{
			_Cells = new List<Cell>();
		}
	}
}
